package com.projectsexception.festivales.setup.xml;

import java.util.ArrayList;
import java.util.List;

import android.content.res.XmlResourceParser;

import com.projectsexception.festivales.setup.MapInfo;

public class XMLHandlerMapInfo extends AbstractXMLHandler<MapInfo> {
    
    private List<MapInfo> maps;
    private MapInfo tmpMapInfo;

    @Override
    public void startDocument() {
        maps = new ArrayList<MapInfo>();
    }

    @Override
    public void startTag(XmlResourceParser res) {
        String s = res.getName();
        if (s.equals("map")) {
            tmpMapInfo = new MapInfo();
            tmpMapInfo.setName(res.getAttributeValue(null, "name"));
            tmpMapInfo.setResourceId(res.getAttributeResourceValue(null, "resourceId", 0));
        }
    }

    @Override
    public void endTag(XmlResourceParser res) {
        if ("map".equals(res.getName())) {
            maps.add(tmpMapInfo);
        }
    }

    @Override
    public List<MapInfo> getResult() {
        return maps;
    }

}
